#ifndef __minhasher__
#define __minhasher__

#include "thisinc.h"
#include "seeds.h"

namespace wpe
{
	static const size_t SEEDS_NUM = sizeof(MIN_SEEDS)/sizeof(uint64_t)/2;

	template < size_t _HASHES_ >
	struct Xmin_hasher
	{
		enum { HASHES = _HASHES_/*SEEDS_NUM */};

		uint64_t hashes[HASHES];
		size_t	 oindex[HASHES];
		long reset()
		{
			for( size_t i = 0; i < HASHES; ++ i )
			{
				hashes[i] = -1LL;
				oindex[i] = -1;
			}
			return S_OK;
		}
		long update( size_t index, uint64_t _hash )
		{
			for( size_t i = 0; i < HASHES; ++ i )
			{
				uint64_t hash_n = MIN_SEEDS[i] * _hash + MIN_SEEDS[i*2+1];
				if( hash_n < hashes[i] )
				{
					hashes[i] = hash_n;
					oindex[i] = index;
				}
			}
			return S_OK;
		}
	};



};


#endif